package com.itfreer.data.report;

import java.util.List;
import java.util.Map;

import com.itfreer.data.report.dao.BaseReportDao;

/**
 * 定义表单下标准Service实现基类
 * 
 * @param <T>
 */
public abstract class BaseReportServiceImp<T> implements BaseReportService<T> {

	protected abstract BaseReportDao getDao();

	@Override
	public String getSqlWhere(T entity, Map<String, Object> where) {
		String sqlWhere = ReportUtil.getWhere(entity, where);
		return sqlWhere;
	}

	@Override
	public List<?> getReports(T entity, Map<String, Object> where, String sql, String ortherWhere) {

		String sqlWhere = this.getSqlWhere(entity, where);

		if ("" != sqlWhere && null != sqlWhere) {
			sql += " and " + sqlWhere;
		}

		if ("" != ortherWhere && null != ortherWhere) {
			sql += " " + ortherWhere;
		}
		List<?> list = getDao().getReportData(sql);
		return list;
	}

}